#ifndef __LDX_CCONSTANTBUFFEROBJECT_H_INCLUDE__
#define __LDX_CCONSTANTBUFFEROBJECT_H_INCLUDE__
#include "LDXConfig.h"
#include "SDeviceMap.h"

namespace ldx
{
	namespace render
	{
		enum E_SET_BUFFER_FLAG
		{
			ESBF_VERTEXX_BUFFER,
			ESBF_INDEX_BUFFER,
		};
		enum E_INDICE_PRIMITIVE_TYPE
		{
			EIPT_TRIANGLELIST = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST
		};

		/**
		* Used to hold the GPU buffer object.
		* Constant buffer, vertex buffer,indice buffer...
		*/
		class CBufferObject
		{
		public:

			CBufferObject(SDeviceMap dm,
				D3D11_USAGE usage,
				uint byteWidth,
				D3D11_BIND_FLAG bindFlags,
				uint cpuAssessFlags = 0,
				void* initData  = 0);

			~CBufferObject();
			
			//for BIND_FLAG is VERTEX_BUFFER
			void setVertexBuffers(uint startSlot,
				uint numBuffers ,
				uint * pstrides ,
				uint * offset );

			//for BIND_FLAG is INDEX_BUFFER
			void setIndexBuffer(DXGI_FORMAT format,
				uint offset=0, E_INDICE_PRIMITIVE_TYPE primitivetype = EIPT_TRIANGLELIST);

			bool updateSubBuffer(void* buffer,
				uint dstSubresource =0 ,
				uint srcRowPithc =0,
				uint srcDepthPitch = 0);

			ID3D11Buffer** getBufferObject()
			{
				return &BufferObj;
			}

			void setDebugName(std::string name);

		private:
			SDeviceMap DM;
			void clearBuffer();
			D3D11_BIND_FLAG BufferType;
			ID3D11Buffer* BufferObj;
		};
	}
}

#endif//! __LDX_CCONSTANTBUFFEROBJECT_H_INCLUDE__